// RMSLog.cpp : implementation file
//

#include "stdafx.h"
#include "RMSLog.h"

#ifdef _RMS_TRANSLATOR_

FILE* LogFile=0;

void CheckLog()
{
	if (LogFile) return;
	LogFile=fopen("server_log.txt","ab");
}

void Write2Log1(char* str,char* str2)
{
	char txt[1000];
	CheckLog();
	sprintf(txt,"MESSAGE-%x:%s %s\r\n",GetCurrentThreadId(),str,str2);
	if (LogFile) {
		fwrite(txt,strlen(txt),1,LogFile);
		fflush(LogFile);
	}
}

void Write2Log2(char* str,int a)
{
	char txt[1000];
	CheckLog();
	sprintf(txt,"MESSAGE-%x:%s %d\r\n",GetCurrentThreadId(),str,a);
	if (LogFile) {
		fwrite(txt,strlen(txt),1,LogFile);
		fflush(LogFile);
	}
}
// tag
void Write2Log3(char* str,int a)
{
	char txt[1000];
	CheckLog();
	sprintf(txt,"MESSAGE-%x:%s %c%c%c%c\r\n",GetCurrentThreadId(),str,a&255,(a>>8)&255,(a>>16)&255,(a>>24)&255);
	if (LogFile) {
		fwrite(txt,strlen(txt),1,LogFile);
		fflush(LogFile);
	}
}

#else //def _RMS_TRANSLATOR_

void CheckLog(){}
void Write2Log1(char* str,char* str2){}
void Write2Log2(char* str,int a){}
void Write2Log3(char* str,int a){}

#endif //def _RMS_TRANSLATOR_
